Skip to content

Add environment DeviceMergeSort#7968

Open
gonidelis wants to merge 2 commits intoNVIDIA:mainfrom
gonidelis:merge_sort_env
Open

Add environment DeviceMergeSort#7968
gonidelis wants to merge 2 commits intoNVIDIA:mainfrom
gonidelis:merge_sort_env

Conversation

@gonidelis
Copy link
Member

@gonidelis gonidelis commented Mar 10, 2026

fixes #7544

Merge sort is inherently stable, so both SortPairs and StableSortPairs naturally satisfy run_to_run determinism.

For StableSort* algorithms we guarantee gpu_to_gpu because stability is part of its API contract.

No refs to determinism were decided to be made

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Mar 10, 2026

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Progress in CCCL Mar 10, 2026
@gonidelis gonidelis changed the title Add env DeviceMergeSort Add environment DeviceMergeSort Mar 10, 2026
@gonidelis gonidelis marked this pull request as ready for review March 10, 2026 07:11
@gonidelis gonidelis requested a review from a team as a code owner March 10, 2026 07:11
@gonidelis gonidelis requested a review from elstehle March 10, 2026 07:11
@cccl-authenticator-app cccl-authenticator-app bot moved this from In Progress to In Review in CCCL Mar 10, 2026
@gonidelis gonidelis enabled auto-merge (squash) March 10, 2026 07:26
@github-actions
Copy link
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 17m: Pass: 100%/249 | Total: 3d 07h | Max: 52m 40s | Hits: 95%/156447

See results here.

Comment on lines +303 to +308
using determinism_t =
::cuda::std::execution::__query_result_or_t<requirements_t,
::cuda::execution::determinism::__get_determinism_t,
::cuda::execution::determinism::run_to_run_t>;
static_assert(!::cuda::std::is_same_v<determinism_t, ::cuda::execution::determinism::gpu_to_gpu_t>,
"gpu_to_gpu determinism is not supported for unstable sort. Use StableSortPairs instead.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I need to figure out what kind of determinism we provide. The merge sort implementation is stable according to the docs, so it should provide gpu to gpu determinism. If you want to steer users away from SortPairs to StableSortPairs, if they need stabililty, that's fine. But even an unstable algorithm can be gpu_to_gpu deterministic.

@gonidelis
Copy link
Member Author

After long discussion with @bernhardmgruber we decided not to specify any deterministic guarantees for DeviceMergeSort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

Add env-based API for cub::DeviceMergeSort

2 participants